import pandas as pd
from wordcloud import WordCloud
import matplotlib.pyplot as plt
words = pd.read_csv('result.csv', header=0)
words = words[words['nature']=='n']
word_freq = words['word'].value_counts().head(100)
# 创建WordCloud对象，并指定中文字体
font_path = 'my_font.TTF'  # 替换为您的中文字体文件路径
wordcloud = WordCloud(width=800, height=400, background_color='white', font_path=font_path).generate_from_frequencies(word_freq)

# 绘制词云
plt.figure(figsize=(10, 5))
plt.imshow(wordcloud, interpolation='bilinear')
plt.axis('off')
plt.show()
